-- 是否是游戏原生基础料理(料理名,是否是大厨料理)
function NUTS_TOOL_IsNativeCookingProduct(name, ismaster)
    -- 普通料理
    if not ismaster then
        for k, v in pairs(require("preparedfoods")) do
            if name == v.name then
                return true
            end
        end
    end
    -- 大厨料理
    for k, v in pairs(require("preparedfoods_warly")) do
        if name == v.name then
            return true
        end
    end
    return false
end

-- 注册贴图集
NUTS_RegisterInventoryItemAtlas = function(atlas_path)
    local atlas = resolvefilepath(atlas_path)

    local file = io.open(atlas, "r")
    local data = file and file:read("*all") or ""
    if file then
        file:close()
    end

    local str = string.gsub(data, "%s+", "")
    local _, _, elements = string.find(str, "<Elements>(.-)</Elements>")
    if elements then
        for s in string.gmatch(elements, "<Element(.-)/>") do
            local _, _, image = string.find(s, "name=\"(.-)\"")
            if image ~= nil then
                RegisterInventoryItemAtlas(atlas, image)
                RegisterInventoryItemAtlas(atlas, hash(image)) -- for client
            end
        end
    end
end

GLOBAL.NUTS_TOOL_IsNativeCookingProduct = NUTS_TOOL_IsNativeCookingProduct
GLOBAL.NUTS_RegisterInventoryItemAtlas = NUTS_RegisterInventoryItemAtlas
